//
//  FileItemModel.m
//  Utils
//
//  Created by enghou on 2018/4/17.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "FileItemModel.h"
#import "NetPath.h"

//image常用格式 .jpg .jpeg .png

//video格式  .mp4

//audio .amr .mp3

@implementation FileItemModel
-(instancetype)initWithSource:(NSDictionary *)source{
    self = [super initWithSource:source];
    if (self) {
        NSString *fileType = [self contentForKey:@"fileType" withSource:source];
        self.suffix = [self contentForKey:@"suffixType" withSource:source];
        if ([fileType isEqualToString:@"document"]) {
            if ([self.suffix isEqualToString:@".jpg"] || [self.suffix isEqualToString:@".jpeg"] || [self.suffix isEqualToString:@".png"]) {
                self.type = Image;
            }else if ([self.suffix isEqualToString:@".mp3"] || [self.suffix isEqualToString:@".amr"]){
                self.type = Audio;
            }else if ([self.suffix isEqualToString:@".mp4"] || [self.suffix isEqualToString:@".avi"] || [self.suffix isEqualToString:@".mov"]){
                self.type = Video;
            }else{
                self.type = Document;
            }
        }else if ([fileType isEqualToString:@"image"]){
            self.type = Image;
        }else if ([fileType isEqualToString:@"video"]){
            self.type = Video;
        }else if ([fileType isEqualToString:@"audio"]){
            self.type = Audio;
        }else{
            self.type = NotDetermined;
        }
        self.path = [self contentForKey:@"path" withSource:source];
//        self.path = [NSString stringWithFormat:@"%@/%@",ServerPath,self.path];
    }
    return self;
}
@end
